package com.bw.lib_imageutils;

import android.content.Context;
import android.widget.ImageView;

import com.bw.lib_imageutils.impl.GlideStrategy;

import java.io.File;

/**
 * @ClassName ImageLoaderManager
 * @Author hu..
 * @Data 2024/7/22
 * @Description
 */
public class ImageLoaderManager {
    private ImageLoaderManager(){
        this(ImageLoaderType.Glide);
    }
    static class HOLDER{
        private static ImageLoaderManager INSTANCE=new ImageLoaderManager();
    }

    public static ImageLoaderManager getInstance(){
        return HOLDER.INSTANCE;
    }

    private IImageLoader imageLoader;
    public ImageLoaderManager(ImageLoaderType type){
        switch (type){
            case Glide:
                imageLoader=new GlideStrategy();
                break;
            case Picasso:
                throw new RuntimeException("Picsso not impl,please wait...");
            default:
                imageLoader=new GlideStrategy();
                break;
        }
    }

    public void loadFileIntoImageView(Context context, String url, ImageView imageView, ImageOptions options){
        imageLoader.loadFileIntoImageView(context,url,imageView,options);
    }
    public void loadFileIntoImageView(Context context, byte[] content, ImageView imageView,ImageOptions options){
        imageLoader.loadFileIntoImageView(context,content,imageView,options);
    }
    public void loadFileIntoImageView(Context context, int resId, ImageView imageView,ImageOptions options){
        imageLoader.loadFileIntoImageView(context,resId,imageView,options);
    }
    public void loadFileIntoImageView(Context context, File file, ImageView imageView, ImageOptions options){
        imageLoader.loadFileIntoImageView(context,file,imageView,options);
    }

}
